import Vue from 'vue'
import Vuex from 'vuex'

import app from './modules/app'
import user from './modules/user'
import permission from './modules/permission'
import teacher from './modules/teacher'
import getters from './getters'
import department from './modules/department'
import yearOptions from './modules/yearOptions'
import createPersistedState from "vuex-persistedstate";
import reportForms from './modules/reportForms'

Vue.use(Vuex)

const store = new Vuex.Store({
  modules: {
    app,
    user,
    permission,
    teacher,
    department,
    yearOptions,
    reportForms
  },
  getters,
  // 持久化所有
  // plugins: [createPersistedState()],
  plugins: [
    createPersistedState({
      storage: window.sessionStorage,
      reducer(val) {
        return {
          // 只储存state中的user
          user: val.user
        }
      }
    })
  ]
})
export default store